import Vue from 'vue'
import Vuex from 'vuex'
import persistedState from 'vuex-persistedstate'

Vue.use(Vuex)

export default new Vuex.Store({
  state: {
    isLoading: false,
    user: {},
    username: '',
    op1: 1,
    op2: 1,
    op3: 1,
    op4: 1,
    op5: 1,
    //  楼层信息
    floor: [],
    floorName: '',
    //  房间信息,以及学生详情介绍
    room: [],
    //  报修
    tableData: [],
    userList: [],
  },
  mutations: {
    setOp5(state, data) {
      syaye.op5 = data
    },
    setOp4(state, data) {
      state.op4 = data
    },
    setUserList(state, data) {
      state.userList = data
    },
    setOp3(state, data) {
      state.op3 = data
    },
    // /数据修改
    changeTableContent(state, data) {
      state.tableData.content = data
    },
    changeTableNumber(state, data) {
      state.tableData.number = data
    },
    //添加报修
    addTableData(state, data) {
      state.tableData.push(data)
    },
    //删除
    removeTableDate(state, data) {
      state.tableData.splice(data, 1)
    },
    //清空
    clearTableDate(state, data) {
      state.tableData = data
    },
    setOp2(state, data) {
      state.op2 = data
    },
    setFloorName(state, data) {
      state.floorName = data
    },
    setRoom(state, data) {
      state.room = data
    },
    setFloor(state, data) {
      state.floor = data
    },
    setOption(state, data) {
      state.op1 = data
    },
    setUsername(state, data) {
      state.username = data
    },
    setUsr(state, data) {
      state.user = data
    },
    change(state, data) {
      state.isLoading = data
    },
  },
  actions: {},
  modules: {},
  plugins: [
    persistedState({
      //保存位置
      storage: window.sessionStorage,
    })
  ]
})
